﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" CodeBehind="EditMyProfile.aspx.cs" Inherits="LizzabethBrownRealEstate.Views.Home.EditMyProfile" %>
<%@ Import Namespace="LizzabethBrownRealEstate.Models" %>
<asp:Content ID="Content2" ContentPlaceHolderID="ScriptPlaceHolder" runat="server">
    <script type="text/javascript">
    $(document).ready(function() {
        $("#frmRegister").validate({
           rules: {
             First: "required",
             Last: "required",
             Phone: "required",
             Email: {
                   required: true,
                   email: true
             }         
           },
           
           errorLabelContainer:"#frmRegisterErr",
           messages: {
             First: "Please enter a first name",
             Last: "Please enter a last name",
             Phone: "Please enter a phone number",
             Email:    {
                required: "Please enter an email address",
                email:    "The email address must be in the proper format"                
             }
           }
        });
    });
    </script>
</asp:Content>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">
<% MembershipUser mu = Membership.GetUser(); %>
<% LBRDataContext dc = new LBRDataContext(); %>
<% User u = dc.GetUser(((Guid)mu.ProviderUserKey).ToString()); if (u == null) u = new User(); %>
<% object userId = new { id = mu.ProviderUserKey.ToString() }; %>
<div class="contentDiv" style="margin-left:25%">
    <form id="frmRegister" method="post" action="<%= Url.Action("UpdateMyProfile", "Users", userId) %>" >
        <fieldset id="fldRegister" style="width:350px;">
            <legend>My Profile</legend>
            <table>
                <tr class="addPropertyRow">
                    <td class="addPropertyLabel"><label class="label" for="txtUserName">User Name:&nbsp;</label></td>
                    <td class="addPropertyField"><%= u.UserName %></td>
                </tr>
                <tr class="addPropertyRow">
                    <td class="addPropertyLabel"><label class="label" for="txtFirst">First Name:&nbsp;</label></td>
                    <td class="addPropertyField"><%= Html.TextBox("First", u.First) %></td>
                </tr>
                <tr class="addPropertyRow">
                    <td class="addPropertyLabel"><label class="label" for="txtLastName">Last Name:&nbsp;</label></td>
                    <td class="addPropertyField"><%= Html.TextBox("Last", u.Last) %></td>
                </tr>
                <tr class="addPropertyRow">
                    <td class="addPropertyLabel"><label class="label" for="txtPhone">Phone:&nbsp;</label></td>
                    <td class="addPropertyField"><%= Html.TextBox("Phone", u.Phone) %></td>
                </tr>
                <tr class="addPropertyRow">
                    <td class="addPropertyLabel"><label class="label" for="txtEmail">Email:&nbsp;</label></td>
                    <td class="addPropertyField"><%= Html.TextBox("Email", u.Email) %></td>
                </tr>
                <tr>
                    <td colspan="2"><div id="frmRegisterErr" class="ValidateErrorContainer"></div></td>
                </tr>
            </table> 
            <%= Html.Hidden("UserName", u.UserName) %>   
        </fieldset>
        <div style="margin-top:15px; margin-bottom:15px">
            <input type="submit" id="btnSubmit" name="btnSubmit" value="Save" />
            <button onclick="window.history.back(); return false;">Return</button>
        </div>
    </form>
</div>
</asp:Content>
